home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / comp / yylexfil.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  882 b   |  30 lines

  1. /*
  2.                                 Y Y L E X F I L . C
  3.  
  4.      Function reading input for yylex() in the standard (file) situation
  5. */
  6.  
  7.  
  8. #include "iccomp.h"
  9.  
  10. int yylex_file(char *buf, int max_size)
  11. {
  12.     int
  13.         result;
  14.  
  15.                                             /* try to read from file */
  16.     if ( (result = read( fileno(yyin), buf, max_size )) > 0 )
  17.         return (result);                    /* return # bytes read if any */
  18.  
  19.     if (result == 0)                        /* if none, switch to other fun */
  20.     {
  21.         clear_hidden();                     /* clear existing hidden names */
  22.         yylex_input = yylex_hidden;         /* connect the buffer-reader */
  23.  
  24.         return (yylex_input(buf, max_size));/* read the hidden source */
  25.     }
  26.  
  27.     error("read() in flex scanner failed"); /* error when read() fails */
  28.     return (0);                    /* dummy to avoid warning */
  29. }
  30.